package demo1;

class Base {
    int a = 101;
    int b = 102;

    public void test(){
        System.out.println("Base :: test");
    }
}

class Derived extends Base{
    //子类和父类不存在同名成员变量
    int c;

    public void method(){
        int a = 10;
        int b = 20;
        int c = 30;
        System.out.println(a);
        System.out.println(b);
        System.out.println(c);
    }

    //子类和父类成员变量同名,全部使用子类的值
    //使用super可以访问到父类的值
    public void method1(){
        System.out.println(super.a);
    }


    ////子类和父类方法名,全部使用子类的方法
    ////使用super可以使用父类的方法
    /// 使用this可以使用到子类的方法
    public void test(){
        System.out.println("Derived :: test");
    }

    public void test1(){
        this.test();
        super.test();

    }
}

public class Test {
    public static void main1(String[] args) {
        Derived derived = new Derived();
        derived.method();;

    }


    public static void main2(String[] args) {
        Derived derived = new Derived();
        derived.method1();
    }

    public static void main3(String[] args) {
        Derived derived = new Derived();
        derived.test();
        derived.test1();
    }
}